package cn.itsy.dao;

import cn.itsy.pojo.*;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class DimissionTDaoImpl implements DimissionTDao {
    @Resource
    private JdbcTemplate jt;

    //查询所有
    @Override
    public List<Emp> queryAll(String sql) {
        List<Emp> query = jt.query(sql, new BeanPropertyRowMapper<Emp>(Emp.class));
        return query;
    }

    //查询部门
    @Override
    public List<Dept> deptAll(String sql) {
        List<Dept> depts = jt.query(sql, new BeanPropertyRowMapper<Dept>(Dept.class));
        return depts;
    }

    //查询职位
    @Override
    public List<Duct> DuctAll(String sql) {
        List<Duct> ducts = jt.query(sql, new BeanPropertyRowMapper<Duct>(Duct.class));
        return ducts;
    }

    //查询职称
    @Override
    public List<Job> JobAll(String sql) {
        List<Job> jobs = jt.query(sql, new BeanPropertyRowMapper<Job>(Job.class));
        return jobs;
    }

    //删除员工
    @Override
    public void del(String sql) {
        jt.update(sql);
    }

    //添加员工
    @Override
    public void add(String sql) {
        jt.update(sql);
    }

    //查询状态
    @Override
    public List<Empstatus> statusAll(String sql) {
        List<Empstatus> statuses = jt.query(sql, new BeanPropertyRowMapper<>(Empstatus.class));
        return statuses;
    }

    //修改员工
    @Override
    public void update(String sql) {
        jt.update(sql);
    }
}
